package com.cn.sl.server.api.system.role.model.dto

import com.cn.sl.server.api.system.menu.model.dto.MenuDto
import com.cn.sl.server.api.system.role.model.entity.RoleEntity
import io.swagger.v3.oas.annotations.media.Schema

@Schema(description = "角色")
data class RoleDto(
    @field:Schema(description = "角色id")
    val id: Long,
    @field:Schema(description = "角色名称")
    val name: String,
    @field:Schema(description = "备注")
    val memo: String?,
    @field:Schema(description = "菜单")
    val menus: List<MenuDto>,
) {
    constructor(entity: RoleEntity) : this(
        entity.id,
        entity.name,
        entity.memo,
        entity.menus.map { MenuDto(it) }
    )
}
